﻿//_______________________________________________________________________________________________________________________
// Copy Right (c) 2010, 2011 SapiensIT Consulting GmbH, all rights reserved
//_______________________________________________________________________________________________________________________
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT
// NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//_______________________________________________________________________________________________________________________
// PROJECT:     sapiens.at.SharePoint (SharePoint 2010/V4)
//_______________________________________________________________________________________________________________________
// VERSION:     2.0
//_______________________________________________________________________________________________________________________
// DESCRIPTION: 
//_______________________________________________________________________________________________________________________
// LICENSE:     Different licens Types apply to different file types:
//               - Source code files are governed by the MICROSOFT PUBLIC LICENSE (Ms-PL)
//               - Binary files are governed by MSDN CODE GALLERY BINARY LICENSE
//               - Documentation files are governed by CREATIVE COMMONS ATTRIBUTION 3.0 LICENSE
//
//               The licenses can be found at the projects source location.
//               If you do not agree, don't use it!
// 
//_______________________________________________________________________________________________________________________
// Start SharePoint Branding, visit http://www.cliggin.com! Visit us on http://www.sapiens.at! Tell your friends! 
//_______________________________________________________________________________________________________________________
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace Sapiens.at.SharePoint.CustomActions
{
    /// <summary>
    /// Represents a configuration for a custom action.
    /// </summary>
    public class CustomActionConfig
    {
        readonly string _command;
        /// <summary>
        /// Gets the command id of this custom action.
        /// </summary>
        public string Command { get { return _command; } }

        /// <summary>
        /// Gets or sets the action that is called when the custom action is invoked.
        /// Leave null to prevent a custom action to invoke a callback.
        /// </summary>
        public Action<string, Page> Callback { get; set; }

        /// <summary>
        /// Gets or sets the javascript that is executed when the custom action is invoked.
        /// </summary>
        public string CallbackScript { get; set; }

        /// <summary>
        /// Gets or sets the function that gets called when the custom action is rendered to determine whether the custom action is enabled.
        /// </summary>
        public Func<Page, bool> IsEnabled { get; set; }

        /// <summary>
        /// Gets or sets the javascript that gets called to determine whether the custom action is enabled.
        /// </summary>
        public string EnabledScript { get; set; }

        /// <summary>
        /// Gets or sets the function to determine whether the custom action is applicable in the current context.
        /// </summary>
        public Func<bool> IsApplicable { get; set; }

        /// <summary>
        /// Gets or sets the action that gets called before the controls are rendered.
        /// </summary>
        public Action<Page> OnPreRender { get; set; }
        
        /// <summary>
        /// Instantiates a configuration for a certain command.
        /// </summary>
        /// <param name="command">The command id this custom action represents</param>
        public CustomActionConfig(string command)
        {
            _command = command;
        }

        public string CallbackParam { get; set; }
    }
}
